#include <cstdio>

int arr[20][20]{};
int res[20][20]{};

int Get (int i, int j, int n, int m) {
    if(i >= 0 && i < n && j >= 0 && j < m){
        return arr[i][j];
    }
    return 0;
}

/**
 * 
 * 时间复杂度：O(n^2)
 * 空间复杂度：O(1)
 * 
 * 学习效率
 * 勤奋值
 * @return 
 */
int main() {



    int n;
    scanf("%d", &n);

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            scanf("%d", &arr[i][j]);
        }
    }

    for(int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            int leftX = i;
            int leftY = j - 1;

            int left = Get(leftX, leftY, n, n);

            int rightX = i;
            int rightY = j + 1;

            int right = Get(rightX, rightY, n, n);

            int topX = i - 1;
            int topY = j;

            int top = Get(topX, topY, n, n);

            int bottomX = i + 1;
            int bottomY = j;

            int bottom = Get(bottomX, bottomY, n, n);

            int leftTopX = i - 1;
            int leftTopY = j - 1;

            int leftTop = Get(leftTopX, leftTopY, n, n);

            int rightTopX = i - 1;
            int rightTopY = j + 1;

            int rightTop = Get(rightTopX, rightTopY, n, n);

            int leftBottomX = i + 1;
            int leftBottomY = j - 1;

            int leftBottom = Get(leftBottomX, leftBottomY, n, n);

            int rightBottomX = i + 1;
            int rightBottomY = j + 1;

            int rightBottom = Get(rightBottomX, rightBottomY, n, n);

            res[i][j] = arr[i][j] + 
                left + right + top + bottom + leftTop + rightTop + leftBottom + rightBottom;
        }
    }

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            printf("%d ", res[i][j]);
        }
        printf("\n");
    }

    return 0;
}
